<?php
namespace app\common\controller;

/**
 * 积分排行榜类
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/12/25
 * Time: 11:06
 */
class IntegralRank{

    /**
     * 获取指定用户积分的排名
     * @param $total_integral
     * @return int
     */
    public function get_user_integral_ranking($total_integral){
        $maps = [];
        $maps[] = ['role','<>',1];
        $maps[] = ['status','=',1];
        $maps[] = ['total_integral','>',$total_integral];
        $ranking = model('user')->get_count($maps,'id');
        if(empty($ranking)){
            $ranking = 0;
        }
        return $ranking + 1;
    }
}